//重置样式
require('../../assets/css/index.less')


//引入weui库
require('../../assets/lib/weui/weui.css')
let weui = require('../../assets/lib/weui/weui.js')

//当前页面样式
require('./badge.less')

//引入字体库
require('../../assets/fonts/iconfont.css')

//引入dom
const dom = require('../../utils/dom.js')

//引入hppts
const https = require('../../utils/https.js')

dom.reday(function () {
    //返回一步
    dom.getEvent('#comeBack', function () {
        history.go(-1)
    })

    //动态渲染
    let liImg = [require('../../assets/imgs/mybadge01.jpg'),
    require('../../assets/imgs/mybadge02.jpg'),
    require('../../assets/imgs/mybadge03.jpg'),
    require('../../assets/imgs/mybadge04.jpg'),
    require('../../assets/imgs/mybadge05.jpg'),
    require('../../assets/imgs/mybadge06.jpg'),
    require('../../assets/imgs/mybadge07.jpg'),
    require('../../assets/imgs/mybadge08.jpg'),
    require('../../assets/imgs/mybadge09.jpg'),
    ]

    function getBadge() {
        https.get('/api/exercise/badge', function (res) {
            console.log(res);
            let { errno, data } = res
            if (errno == 0) {
                //渲染到页面上
                data.map(v=>{
                    console.log(v);
                    dom.getEle('#badgeUl').innerHTML += `
                    <li>
                    <img src="${liImg[v.id-1]}" alt="">
                    <p>${v.name}</p>
                    </li>
                    `
                })

                dom.getEle('#badgeUl').innerHTML += `
                <li>
                <img src="${liImg[liImg.length-1]}" alt="">
                </li>
                `
               
            }
        })
    }

    getBadge()




})